<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<link href="./css/ltcss.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PayChannel</title>
<link href="styles/general.css" rel="stylesheet" type="text/css">
<link href="styles/main.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/validator.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dojo/resources/dojo.css" />
	<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dijit/themes/tundra/tundra.css" />
	<script src="http://ajax.pupkk.com/dojo/1.7.5/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
    <script type="text/javascript">
		dojo.require("dojo.parser");
		dojo.require("dijit.form.DateTextBox");
		dojo.require("dijit.form.FilteringSelect");
function txcheck(){
	return formvalidator("all");
}
function formvalidator(obj)
{
	var controlId = "all";
	 if (typeof(obj) != "string" )
	 {
		 controlId = obj.id;
	 }
	if(controlId=="all" || controlId=="cpaccount.id")
	{
		if(Utils.trim(document.getElementById("cpaccount.id").value)=="")
		{
			document.getElementById("CompareValidator1").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator1").style.visibility="hidden";
		}
	}
	if(controlId=="all" || controlId=="cpaccount.name")
	{
		if(Utils.trim(document.getElementById("cpaccount.name").value)=="")
		{
			document.getElementById("CompareValidator2").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator2").style.visibility="hidden";
		}
	}
	if(controlId=="all" || controlId=="cpaccount.password")
	{
		if(Utils.trim(document.getElementById("cpaccount.password").value)=="")
		{
			document.getElementById("CompareValidator3").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator3").style.visibility="hidden";
		}
	}
	var account_type = document.getElementById("cpaccount.type").value;
	 if(account_type==0)
	 {
		 if(controlId=="all" || controlId=="cpId")
			{
			 	var ids = document.getElementsByName("cpId");  
			 	var f = 0;     
			    for (var i = 0; i < ids.length; i++)        
			    {              
			            if(ids[i].checked==true)
			            {
				            f = 1;
			            }
			    }    
			    if(f ==0)
			    {
				    alert('请选择关联CP！');
				    return false;
			    }   
			}
	 }else
	 {
		 if(controlId=="all" || controlId=="channelid")
			{
				var ids = document.getElementsByName("channelid");  
			 	var f = 0;     
			    for (var i = 0; i < ids.length; i++)        
			    {              
			            if(ids[i].checked==true)
			            {
				            f = 1;
			            }
			    }    
			    if(f ==0)
			    {
				    alert('请选择关联渠道！');
				    return false;
			    }
			}
	 }
	 if(controlId=="all" || controlId=="cpaccount.menuvalue")
		{
			var ids = document.getElementsByName("cpaccount.menuvalue");  
		 	var f = 0;     
		    for (var i = 0; i < ids.length; i++)        
		    {              
		            if(ids[i].checked==true)
		            {
			            f = 1;
		            }
		    }    
		    if(f ==0)
		    {
			    alert('请选择权限！');
			    return false;
		    }
		}
	return true;
}

function chkAll(vl,name)
{
	var v = document.getElementsByName(name);
	for(var i=0;i<v.length;i++)
	{
		v[i].checked=vl;
	}
	
}

function account_type_onchange()
{
	 var account_type = document.getElementById("cpaccount.type").value;
	 if(account_type==0)
	 {
		 document.getElementById("cpdiv").style.display="";
		 document.getElementById("channeldiv").style.display="none";
	 }else
	 {
		 document.getElementById("cpdiv").style.display="none";
		 document.getElementById("channeldiv").style.display="";
	 }
}

</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="cpaccount_save.do?type=<s:property value="type" />" onsubmit="return txcheck();">
 <input type="hidden" id="cpaccount.createuser" name="cpaccount.createuser"  value="<s:property value="cpaccount.createuser" />" />
 <input type="hidden" id="cpaccount.createdate" name="cpaccount.createdate"  value="<s:property value="cpaccount.createdate" />" />
 <h1> 
        <span class="action-span"><a href="cpaccount_list.do">客户账号列表</a></span> <span
            class="action-span1"><a href="">
                首页</a> </span><span id="search_id" class="action-span1">- 客户账号管理 </span>
        <div style="clear: both">
        </div>
    </h1>
 <div style="margin-bottom: 5px;" class="list-div">
        <table width="100%" cellspacing="1" cellpadding="3">
            <tbody>
                <tr>
                    <th colspan="2">
                        	基本信息
                    </th>
                </tr>
                <tr> 
				    <td  class="label"><div align="right">ID：</div></td> 
				    <td>
					    <input id="cpaccount.id" name="cpaccount.id" type="text" size="60" 
          					value="<s:property value="cpaccount.id" />" <s:if  test="type.equals('update')" >readonly="readonly"</s:if> />
						<span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator1" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr> 
				    <td class="label"><div align="right">名称：</div></td> 
				    <td >
				     <input id="cpaccount.name" name="cpaccount.name" type="text" size="60" 
          				value="<s:property value="cpaccount.name" />"/>
					   <span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator2" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr <s:if test="type.equals('update')">style="display:none;"</s:if>> 
				    <td class="label"><div align="right">密码：</div></td> 
				    <td >
				    	<input id="cpaccount.password" name="cpaccount.password" type="text" size="60"
          				value="<s:property value="cpaccount.password" />" />
          				 <span id="CompareValidator3" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr>
				      <td class="label"><div align="right">类型：</div></td>
				      <td>
				      <select id="cpaccount.type" name="cpaccount.type" onchange="account_type_onchange()">
				        <option value="0" <s:if test="cpaccount.type==0">selected</s:if>>CP用户</option>
				        <option value="1" <s:if test="cpaccount.type==1">selected</s:if>>渠道用户</option>
				      </select>
				    </tr>
					    <tr id="cpdiv" name="cpdiv" <s:if test="cpaccount.type==1">style="display:none;"</s:if>>
					      <td class="label"><div align="right">cp：</div></td>
					      <td>
					      <table>
					          <tr>
					          <s:iterator value="cpInfos" status="stat2" id="pro">
					            <s:if test="#stat2.index>0 && #stat2.index%5==0"></tr>	<tr>					            
					            </s:if>
					            <td>
					             	<input type="checkbox" id="cpId" name="cpId" value="<s:property value="id"/>" 
					              	<s:if test="(','+cpaccount.cpId+',').indexOf(','+id+',')>=0" >checked</s:if>/><s:property value="cpName"/>             
					             </td>
						        </s:iterator> 
					            <!--<s:if test="cpInfos.size()%6!=0">
					              <td colspan="<s:property value="6-cpInfos.size()%6" />">&nbsp;</td>
					            </s:if>-->
					            </tr>
					       </table>
					       </td>
					    </tr>
					     <tr id="channeldiv" name="channeldiv" <s:if test="type.equals('insert')">style="display:none;"</s:if> <s:if test="cpaccount.type==0">style="display:none;"</s:if>>
					      <td class="label"><div align="right">渠道：</div></td>
					      <td>
					      <table>
					          <tr>
					          <s:iterator value="channels" status="stat2" id="pro">
					            <s:if test="#stat2.index>0&&#stat2.index%5==0">	</tr>	<tr>				            
					            </s:if>
					            <td>
					              &nbsp;&nbsp;<input type="checkbox" id="channelid" name="channelid" value="<s:property value="id"/>" 
					              <s:if test="(','+cpaccount.channelid+',').indexOf(','+id+',')>=0" >checked</s:if>
					               />&nbsp;<s:property value="name"/>             
					             </td>
					            </s:iterator>
					            <!--<s:if test="channels.size()%5!=0">
					              <td colspan="<s:property value="5-channels.size()%5" />">&nbsp;</td>
					            </s:if>-->
					            </tr>
					         </table>
					    </tr>
					    <tr>
				      <td class="label"><div align="right">权限：</div></td>
				      <td>&nbsp;
				      <input type="checkbox" id="cpaccount.menuvalue" name="cpaccount.menuvalue" <s:if test="cpaccount.menuvalue.indexOf('cps')>-1">checked</s:if> value="cps"/>数据查询（cps合作）
				   	  <input type="checkbox" id="cpaccount.menuvalue" name="cpaccount.menuvalue" <s:if test="cpaccount.menuvalue.indexOf('cpa')>-1">checked</s:if> value="cpa"/>用户数查询（cpa合作）
				    </tr>
				  <tr> 
				    <td class="label"><div align="right">描述：</div></td> 
				    <td >
					   <textarea name="cpaccount.remark" id="cpaccount.remark" rows="6" cols="60"><s:property value="cpaccount.remark" /></textarea>
                    </td>
				  </tr>			 
				  <tr>
                    <td colspan="2" align="center">
                     <s:if test="isUpdate.equals('true')">
					    <input type="submit" value=" 确定 " class="button" />
					 </s:if>
                        &nbsp;&nbsp;&nbsp;
                        <input type="reset" value=" 重置 " class="button" />
                    </td>
                </tr>
	 	</tbody>
	 </table>
 </div>
</form>
 <!--Bottom开始-->
    
<div id="footer">
<br />
<s:property value="bottom"/></div>
    <!--Bottom结束-->
  
</body>
</html>